package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.deposit;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.SQLDeleteAll;
import org.hibernate.annotations.Where;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author liwei
 * 保证金管理-每日试算
 */
@Data
@Entity
@Table(name = "t_depository_day_trial")
@org.hibernate.annotations.Table(appliesTo = "t_depository_day_trial", comment = "每日收益")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Where(clause = "deleted = 'N'")
@SQLDelete(sql = "update t_depository_day_trial set deleted = 'Y' where id=?")
@SQLDeleteAll(sql = "update t_depository_day_trial set deleted = 'Y' where id=?")
public class DepositoryDayTrial implements Serializable {
    private static final long serialVersionUID = -4329617526889041281L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int(20) comment 'id'")
    private Integer id;

    @Column(name = "bank_id", columnDefinition = "int(20) comment '存管银行id'")
    private Integer bankId;

    @ApiModelProperty(value = "银行名称")
    @Column(name = "bank_name", columnDefinition = "varchar(255) COMMENT '银行名称'")
    private String bankName;

    @ApiModelProperty(value = "生效日期")
    @Column(name = "effect_date", columnDefinition = "varchar(255) COMMENT '生效日期yyyy-MM-dd'")
    private String effectDate;

    @ApiModelProperty(value = "16:00柜台余额")
    @Column(name = "counter_balance", columnDefinition = "decimal(16,4) COMMENT '16:00柜台余额'")
    private BigDecimal counterBalance;

    @ApiModelProperty(value = "16:00银行余额")
    @Column(name = "bank_balance", columnDefinition = "decimal(16,4) COMMENT '16:00银行余额'")
    private BigDecimal bankBalance;

    @ApiModelProperty(value = "利率")
    @Column(name = "interest_rate", columnDefinition = "decimal(16,4) COMMENT '利率'")
    private BigDecimal interestRate;

    @ApiModelProperty(value = "16:00利息")
    @Column(name = "interest", columnDefinition = "decimal(16,4) COMMENT '16:00利息'")
    private BigDecimal interest;

    @ApiModelProperty(value = "最低存放")
    @Column(name = "deposit_floor", columnDefinition = "decimal(16,4) COMMENT '最低存放'")
    private BigDecimal depositFloor;

    @ApiModelProperty(value = "调整试算")
    @Column(name = "adjust_trial", columnDefinition = "decimal(16,4) COMMENT '调整试算'")
    private BigDecimal adjustTrial;

    @ApiModelProperty(value = "手动调整")
    @Column(name = "hand_adjust", columnDefinition = "decimal(16,4) COMMENT '手动调整'")
    private BigDecimal handAdjust;

    @ApiModelProperty(value = "合计调整金额")
    @Column(name = "sum_adjust", columnDefinition = "decimal(16,4) COMMENT '合计调整金额'")
    private BigDecimal sumAdjust;

    @ApiModelProperty(value = "试算利息变动")
    @Column(name = "trial_interest_change", columnDefinition = "decimal(16,4) COMMENT '试算利息变动'")
    private BigDecimal trialInterestChange;

    @ApiModelProperty(value = "当日净买入")
    @Column(name = "purchase_day", columnDefinition = "decimal(16,4) COMMENT '当日净买入'")
    private BigDecimal purchaseDay;

    @ApiModelProperty(value = "当日净取款")
    @Column(name = "withdrawal_day", columnDefinition = "decimal(16,4) COMMENT '当日净取款'")
    private BigDecimal withdrawalDay;

    @ApiModelProperty(value = "备注")
    @Column(name = "memo", columnDefinition = "varchar(255) COMMENT '备注'")
    private String memo;

    @Column(name = "create_id", columnDefinition = "int DEFAULT NULL COMMENT '创建人id'")
    @ApiModelProperty(value = "创建人id")
    private Long createId;

    @ApiModelProperty(value = "创建人名称")
    @Column(name = "create_name", columnDefinition = "varchar(100) COMMENT '创建人名称'")
    private String createName;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty(value = "是否删除，字典 YesNo:（N=未删除(默认) Y=已删除)")
    @Column(name = "deleted", columnDefinition = "varchar(20) default 'N' COMMENT '是否删除，字典 yesno （N=否(默认) Y=是)'")
    private String deleted = DictConstant.NO;

    @ApiModelProperty(value = "T+1日可取")
    @Column(name = "after_day_extract", columnDefinition = "decimal(16,4) COMMENT 'T+1日可取'")
    private BigDecimal afterDayExtract;

    @ApiModelProperty(value = "值")
    @Transient
    private BigDecimal accountValue;


}
